package servlet.comm;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import factory.comm.StudioDAOFactory;
import vo.comm.Studio;




public class JoinStudioServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public JoinStudioServlet() {
        super();
    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String userid=(String)request.getSession().getAttribute("userid");
		String username=(String) request.getSession().getAttribute("username");
		Studio studio=new Studio();
		studio.setUserid(userid);
		studio.setUsername(username);
		response.setContentType("text/html; charset=UTF-8");
		try {
			if(StudioDAOFactory.getIStudioDAOInstance().doJoin(studio)){
				response.sendRedirect("studio/join_success.jsp");
			}
			else{
				response.sendRedirect("studio/join_failure.jsp");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

}
